﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Template/Site_Main.Master" AutoEventWireup="true"
    CodeBehind="main.aspx.cs" Inherits="RegisterationSystem.Space_Preschools.main" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
      <!--
    $(function () {
        //初始化隐藏层
        $('#plastudentinfo').dialog({
            closed: true
        });
        //初始化隐藏层
        $('#plastudentdeleteinfo').dialog({
            closed: true
        });
        //初始化隐藏层
        $('#plastudentupdateinfo').dialog({
            closed: true
        });
        //初始化隐藏层
        $('#planoticinfo').dialog({
            closed: true
        });
        //初始化企业用户数据列表控件
        $("#dg").datagrid({
            idField: "id",      //标识字段,主键
            url: "../SyncService/GetDataList.ashx?action=GetPreschoolsID",
            queryParams: { "where": "1=1", "typeid": "0" },
            pagination: true,   //是否开启分页
            rownumbers: true,   //行号
            pageSize: 10,
            pageNumber: 1,
            columns: [[
                         { field: 'ck', checkbox: true },
                        { field: 'Name', title: '幼儿园名称', width: 120, align: 'center' },
                        { field: 'AccountName', title: '用户名', width: 130, align: 'center' },

                        {
                            field: 'id', title: '查看详细信息', width: 255.5, align: 'center', formatter: function (value, row) {
                                return "<a  href='javascript:void(0)' onclick='updstatusbyid(" + value + ",2)'>初审通过</a>&nbsp;&nbsp;<a  href='javascript:void(0)' onclick='updstatusreason(" + value + ",3)'>放弃</a>&nbsp;&nbsp;<a href='javascript:void(0)' onclick='delstudentByID(" + value + ")'>删除</a>&nbsp;&nbsp;<a href='javascript:void(0)'  onclick='GetByStudentInfo(" + value + ");'>查看详细信息</a>";

                            }
                        }
            ]]
        })
    });
    //-->

    //弹出学生详细信息
    function GetByStudentInfo(stdID) {
        $.post("../SyncService/GetDataList.ashx",
            { "action": "GetStudentByID", "id": stdID },
            function (cStr) {
                var stdInfo = eval('(' + cStr + ')');
                $("#<%= hidstuID.ClientID %>").val(stdID);
                $("#spanname").text(stdInfo.name); //姓名
                $("#spansex").text(stdInfo.sex); //性别
                $("#spanbirthday").text(stdInfo.birthday); //出生年月
                $("#spanidcardnumber").text(stdInfo.idcardnumber); //学生身份证
                $("#HouseIngoingTime").text(stdInfo.HouseIngoingTime); //户口迁入时间
                $("#HousingOccupancyTime").text(stdInfo.HousingOccupancyTime); //住房入住时间
                $("#PermanentAddress").text(stdInfo.PermanentAddress); //户籍地址
                //$("#spanhobby").text(stdInfo.hobby); //兴趣爱好
                $("#spanfirstguardianname").text(stdInfo.firstguardianname); //第一监护人
                $("#spanfirstguardianunit").text(stdInfo.firstguardianunit); //工作单位
                $("#spanfirstguardianphone").text(stdInfo.firstguardianphone); //联系电话
                $("#spansecguardianname").text(stdInfo.secguardianname); //第二监护人
                $("#spansecguardianunit").text(stdInfo.secguardianunit); //工作单位
                $("#spansecguardianphone").text(stdInfo.secguardianphone); //联系电话
                switch (stdInfo.houseareaid) {
                    case "0":
                        $("#spanhouseareaid").text("武汉经济技术开发区（汉南区）"); //户口所在地
                        break;
                    case "1":
                        $("#spanhouseareaid").text("市内其它区"); //户口所在地
                        break;
                    case "2":
                        $("#spanhouseareaid").text("省内市外、外省外市"); //户口所在地
                        break;
                    case "3":
                        $("#spanhouseareaid").text("外籍(含港澳台)"); //户口所在地 ;
                        break;
                }
                $("#spanscommname").text(stdInfo.scommname); //住房社区
                $("#spanxcommname").text(stdInfo.xcommname); //住房小区
                $("#spanhousenumber").text(stdInfo.housenumber); //门牌号
                $("#spanhousecard").text(stdInfo.housecard); //房产号
                $("#spanfirstrelationship").text(stdInfo.firstrelationship); //与学生关系
                $("#spansecrelationship").text(stdInfo.secrelationship); //与学生关系
                $("#txtPhoneStatusText").val(stdInfo.phonestatustext);
            },
                "text");
        //弹层
            $('#plastudentinfo').dialog({
                title: '学生信息',
                width: 600,
                height: 405,
                closed: false,
                cache: false,
                modal: true,
                collapsible: true,
                maximizable: false
            });
        }

        //重置学生用户密码
        function UpdStudentPswdReset(StudentPswd) {
            $.messager.confirm('提示', '确认重置密码？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "pswdreset", "id": $("#<%= hidstuID.ClientID %>").val(), "StudentPswd": StudentPswd }, function (data) {
                            $.messager.alert("消息提示", "重置成功！");
                            $('#plastudentinfo').dialog("close");
                            $('#dg').datagrid('reload');
                        });
                    }
                });
            }


            //根据ID选择删除学生原因
            function delstudentByID(id) {
                $("#<%= hiddeletestuID.ClientID %>").val(id);
            //弹层
            $('#plastudentdeleteinfo').dialog({
                title: '删除原因说明',
                width: 300,
                height: 150,
                closed: false,
                cache: false,
                modal: true,
                collapsible: true,
                maximizable: false
            });
        }
        //根据ID删除学生
        function QRdelstudentByID() {
            if ($("#<%= hiddeletestuID.ClientID %>").val() == "-1n") {
                $("#plastudentdeleteinfo").dialog("close");
                //id集合
                var ids = "";
                //获取选择集合
                var rows = $('#dg').datagrid('getSelections');
                if (rows.length == 0) {
                    alert("请选择行");
                    return;
                }
                //遍历选择行
                for (var i = 0; i < rows.length; i++) {
                    ids += rows[i].id + ",";
                }
                $.messager.confirm('提示', '删除原因一致吗？', function (r) {
                    if (r) {
                        $.messager.confirm('提示', '确认删除？', function (r) {
                            if (r) {
                                $.post(location.href, { "action": "delstudentlist", "id": ids, "deletereason": $("#deletereason").combobox('getValue') }, function (data) {
                                    $.messager.alert("消息提示", "删除成功！");
                                    $('#dg').datagrid('reload');
                                });
                            }
                        });
                    }
                });
            }
            else {
                $("#plastudentdeleteinfo").dialog("close");
                $.messager.confirm('提示', "是否确认删除？", function (r) {
                    if (r) {
                        $.post(location.href, { "action": "delstudentByID", "id": $("#<%= hiddeletestuID.ClientID %>").val(), "deletereason": $("#deletereason").combobox('getValue') }, function (data) {
                            $.messager.alert("消息提示", "删除成功!");
                            $('#dg').datagrid('reload');
                        });
                    }
                });
            }
        }
        //批量删除
        function delstudentlist() {
            var rows = $('#dg').datagrid('getSelections');
            if (rows.length == 0) {
                alert("请选择行");
                return;
            }
            $("#<%= hiddeletestuID.ClientID %>").val("-1n");
            //弹层
            $('#plastudentdeleteinfo').dialog({
                title: '删除原因说明',
                width: 300,
                height: 150,
                closed: false,
                cache: false,
                modal: true,
                collapsible: true,
                maximizable: false
            });
        }


        //弹出公告层
        function selnoice(id) {
            $.post("../SyncService/GetDataList.ashx",
                { "action": "GetNoticeByID", "id": id },
                function (cStr) {
                    var stdInfo = eval('(' + cStr + ')');
                    $("#txttilt").text(stdInfo.tile); //标题
                    $("#txtcount").text(stdInfo.content); //内容
                },
                "text");
            //弹层
            $('#planoticinfo').dialog({
                title: '公告信息',
                width: 400,
                height: 200,
                closed: false,
                cache: false,
                modal: true,
                collapsible: true,
                maximizable: false
            });
        }


        //把符合条件选定的数据导出excel
        function derive_excel() {
            var mess = "";
            var altmess = "";
            mess = "确认导出excel？";
            altmess = "导出excel成功!"
            //id集合
            var ids = "";
            //获取选择集合
            var rows = $('#dg').datagrid('getSelections');
            if (rows.length == 0) {
                alert("请选择行");
                return false;
            }
            //遍历选择行
            for (var i = 0; i < rows.length; i++) {
                ids += rows[i].id + ",";
            }
            $.messager.confirm('提示', mess, function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "../SyncService/ExcelHelper.ashx?type=derive_excelList&id=" + ids,
                        //                data: { "type": "loadReport", "typeid": "0", "where": "" + where + "" },
                        datatype: "text",
                        cache: false,
                        success: function (data) {
                            if (data == "0") {
                                alert("导出excel失败");
                            }
                            else {
                                try {
                                    window.location = data;
                                } catch (e) {

                                }
                            }
                        }
                    });
                    //                    $.post(location.href, { "action": "derive_excelList", "id": ids }, function (data) {
                    //                        window.location = data;
                    //                    });

                }
            });
            //            $.messager.confirm('提示', mess, function (r) {
            //                if (r) {
            //                    $.post(location.href, { "action": "derive_excelList", "id": ids }, function (data) {
            //                        window.location = data;
            //                    });

            //                }
            //            });
        }

        //把符合条件的所以数据导出excel
        function derive_excelAll() {
            var mess = "";
            mess = "确认导出excel？";
            var where = "1=1";
            $.messager.confirm('提示', mess, function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "../SyncService/ExcelHelper.ashx?type=derive_excelListAll&typeid=0&where=" + where,
                        //                data: { "type": "loadReport", "typeid": "0", "where": "" + where + "" },
                        datatype: "text",
                        cache: false,
                        success: function (data) {
                            if (data == "0") {
                                alert("导出excel失败");
                            }
                            else {
                                try {
                                    window.location = data;
                                } catch (e) {

                                }
                            }
                        }
                    });
                }
            });
            //            $.messager.confirm('提示', mess, function (r) {
            //                if (r) {
            //                    $.post(location.href, { "action": "derive_excelListAll", "where": where, "typeid": "0" }, function (data) {
            //                        window.location = data;
            //                    });

            //                }
            //            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <!--选择要删除的学生信息编号-->
    <asp:HiddenField ID="hiddeletestuID" runat="server" />
     <!--选择要放弃的学生信息编号-->
    <asp:HiddenField ID="hidupdatestuID" runat="server" />
       <!--选择的学生信息编号-->
    <asp:HiddenField ID="hidstuID" runat="server" />
    <div class="loadheight">
        <table width="100%%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td bgcolor="#FFFFFF">
                  <div style="height: 5px;">
                    </div>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_top">
                                <strong>公告信息</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                 <table width="100%"; border="0" cellspacing="0" cellpadding="0" style="margin: 0px auto;">
                 <tr>
                  <td>
                    <ul style="margin: 0px; padding: 0px; width: 100%; text-align: left;">
                        <asp:Repeater ID="Repeater2" runat="server">
                            <ItemTemplate>
                                <li style="width: 49%; height: 24px; line-height: 24px; background: url(../images/la.png) no-repeat 8px center;
                                    text-indent: 30px; margin: 0px; padding: 0px; float: left;"><a href="javascript:void(0)"
                                        onclick="selnoice(<%#Eval("id") %>);">
                                        <%#Eval("Tile")%></a></li>
                            </ItemTemplate>
                        </asp:Repeater>
                    </ul>
                  </td>
                 </tr>
                 </table>
                            </td>
                        </tr>
                    </table>

                    <div style="height: 5px;">
                    </div>
                    
                    <div style="height: 5px;">
                    </div>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>幼儿园信息</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <!-- 创建数据列表控件 -->
                                <table id="dg" style=" width:1045px">
                                </table><br />
                                <br />

                 <table style="align:center; width:500px" cellspacing="0" cellpadding="0" border="1">
                <tr>
                    <td>学生姓名</td>
                    <td>幼儿园名称</td>
                    <td>学校名称</td>
                </tr>
           <%foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
             {%>

            <tr>
                <td><%=dr["学生姓名"] %></td>
                  <td><%=dr["幼儿园名称"] %></td>
                  <td><%=dr["学校名称"] %></td>
            </tr>
           <% } %>  
               </table>

                                <div style="margin-top: 15px;">
                                </div>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td align="left">
                                            <input type="button" name="button1" id="button1" value="查询" class="anniu" width="73px"
                                                height="23px" onclick="" />
                                            <input type="button" name="button2" id="button2" value="删除" class="anniu" width="73px"
                                                height="23px" onclick="" />
                                                   <input type="button" name="button1" id="button6" value="选定导出Excel" class="anniu_big" width="73px"
                                                height="23px" onclick="derive_excel();" />
                                                <input type="button" name="button1" id="button7" value="全部导出Excel" class="anniu_big"
                                                height="23px" onclick="derive_excelAll();" />
                                        </td>
                                    </tr>
                                </table>
                                <div style="margin-top: 10px;">
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <!--弹出公告详细信息-->
    <div id="planoticinfo" class="easyui-dialog tcc_M" style="padding-top:5px">
        <ul>
            <li>&nbsp;公告标题：<span id="txttilt"></span> </li>
            <li>&nbsp;</li>
            <li>&nbsp;公告类容： <span id="txtcount"></span></li>
        </ul>
    </div>
    <!--弹出学生详细信息-->
    <div id="plastudentinfo" class="easyui-dialog tcc_M">
        <div class="tcc_div" style="margin-left: 20px;">
            <ul>
                 <li class="tcc_BT">幼儿园详细信息</li>
                <li>姓名：<span id="spanname"></span></li>
                <li>性别：<span id="spansex"></span></li>
                <li>证件号(身份证/护照)：<span id="spanidcardnumber"></span>&nbsp;<a href='javascript:void(0)' onclick='UpdStudentPswdReset(123456);' style="color:#990000">密码重置</a></li>
                <li>出生年月：<span id="spanbirthday"></span></li>
                <li>户口所在地：<span id="spanhouseareaid"></span></li>
                <li>住房社区：<span id="spanscommname"></span></li>
                <li>住房小区：<span id="spanxcommname"></span></li>
                <li>门牌号：<span id="spanhousenumber"></span></li>
                <li>房产证号：<span id="spanhousecard"></span></li>
                <li>户口迁入时间：<span id="HouseIngoingTime"></span></li>
                <li>住房入住时间：<span id="HousingOccupancyTime"></span></li>
                <li>户籍地址：<span id="PermanentAddress"></span></li>
                <%--<li>兴趣爱好：<span id="spanhobby"></span></li>--%>
            </ul>
        </div>
        <div class="tcc_div" style="float: right">
            <ul>
                 <li class="tcc_BT">监护人信息</li>
                <li>第一监护人：<span id="spanfirstguardianname"></span></li>
                <li>与学生关系：<span id="spanfirstrelationship"></span></li>
                <li>工作单位：<span id="spanfirstguardianunit"></span></li>
                <li>联系电话：<span id="spanfirstguardianphone"></span></li>
                <li>&nbsp;</li>
                <li>第二监护人：<span id="spansecguardianname"></span></li>
                <li>与学生关系：<span id="spansecrelationship"></span></li>
                <li>工作单位：<span id="spansecguardianunit"></span></li>
                <li>联系电话：<span id="spansecguardianphone"></span></li>
            </ul>
        </div>
    </div>
        <div id="plastudentdeleteinfo" class="easyui-dialog tcc_M" style=" padding-top:15px; padding-left:30px">
     <ul>
                <li>删除原因： <select id="deletereason" class="easyui-combobox" data-options="required:true,editable:false">
                                                            <option value="无效身份证号">无效身份证号</option>
                                                            <option value="信息杂乱">信息杂乱</option>
                                                        </select></li>
                                                        <li style="margin-top:15px; margin-left:66px"><input type="button" name="button1" id="button5" value="确认删除" class="anniu" width="73px"
                                                height="23px" onclick="QRdelstudentByID();" /></li>
            </ul>
    </div>   
</asp:Content>
